home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 132_01 / pass1.c < prev    next >
Text File  |  1985-08-19  |  2KB  |  110 lines

  1. /*
  2.     pass1 checks for overlapping objects and calls for rewrites
  3.     where required.
  4. */
  5. pass1(mptr,pgptr,pscrn)
  6. int    *mptr,*pgptr,*pscrn;
  7. {
  8. int    *pgscan,mflag,pgflag;
  9.  
  10.     pgscan=pgptr;
  11.  
  12.     while(pgscan[FORWARD] != NULL) {
  13.         pgflag=pgscan[FLAGS];
  14.         if(pgflag&WRITE) { /* if a write */
  15.             rewrite(pgscan,pgptr);
  16.               }
  17.         pgscan=pgscan[FORWARD];
  18.     }
  19. }
  20. /*
  21.     Rewrite     scans a page list for any object which is not
  22.     BLANKED or already flagged for WRITE. If the two objects
  23.     overlap, then the tested object in the page list is 
  24.     flagged for a write.
  25.  
  26.     Entry    : pointer to current page list entry
  27.           pointer to head of page list to scan
  28.     Exit    : Returns 1 if at least one overlap acted on.
  29.           Returns 0 if no overlaps.
  30.     Calls    : Overlap
  31. */
  32. rewrite(pscan,pscan1)
  33. int    *pscan,*pscan1;
  34. {
  35. int    update;
  36. update = NULL;
  37.     while(pscan1[FORWARD] != NULL) {
  38.         if(pscan1 != pscan)    { /* avoid same object */
  39.             if(((BLANKED+WRITE)&pscan1[FLAGS])==0) {
  40.                 if(overlap(pscan,pscan1)) {
  41.                  pscan1[FLAGS]=pscan1[FLAGS] + WRITE;
  42.                  update++;
  43.                 }
  44.             }
  45.         }
  46.         pscan1=pscan1[FORWARD];
  47.     }
  48. return(update);
  49. }
  50. /*
  51.     Overlap tests for two objects in the same space.
  52.     Entry    : A pointer to each scan list entry.
  53.     Exit    : Null if no overlap, 1 if overlap
  54.     Calls    : None
  55.         Linkage to object definition list via scan pointers.
  56. */
  57. overlap(scan,scan1)
  58. int    scan[],scan1[];
  59. {
  60. int    xleft,xm,yupper,ym,xright,ylower,temp;
  61. int    *obj;
  62. /*
  63.     Ascertain the left-most (x) and upper (y) objects.
  64. */
  65.     xleft= scan[X];
  66.     xright    = scan1[X];    /* assume this is correct */
  67.     obj    = scan[OBJPTR];
  68.     if(xleft > xright)     { /* if assumption invalid,switch */
  69.         temp = xright;
  70.         xright = xleft;
  71.         xleft  = temp;
  72.         obj    = scan1[OBJPTR];
  73.     }
  74.     xm= 255&(PIXBYT*obj[XMAX]);
  75.     yupper    = scan[Y];    /* same procedure for y axis */
  76.     ylower  = scan1[Y];
  77.     obj     = scan[OBJPTR];
  78.     if(yupper > scan1[Y]) {
  79.         temp    = yupper;
  80.         yupper    = ylower;
  81.         ylower    = temp;
  82.         obj    = scan1[OBJPTR];
  83.     }
  84.     ym    = 255&obj[YMAX];
  85.     if((xleft + xm)>= xright)
  86.         if((yupper + ym)>= ylower)
  87.             return 1;
  88.     return 0;
  89. }
  90.  
  91. n 0;
  92. }
  93.  
  94. rn 0;
  95. }
  96.  
  97. ;
  98.     return 0;
  99. }
  100.  
  101. ;
  102.     return 0;
  103. }
  104.  
  105. ;
  106.     return 0;
  107. }
  108.  
  109.  
  110.     retu